package toanstt.com.MatchUp;





import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;



import toanstt.com.MatchUp.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {

	App app;
	static public AdView adView;
	public static MainActivity activity;
	 public static Context context ;
	 public static FrameLayout.LayoutParams adsParams;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    	activity = this;
        super.onCreate(savedInstanceState);
        context = getApplicationContext();
        T.Init_loading(this);
        //setContentView(R.layout.main_lay);
        //adView = (AdView )(findViewById(R.id.adView));        
        //app = (App)findViewById(R.id.gameBoard1);
        
        
        if(T.ISHORIZONTAL)
        {
        	//if(T.DISPLAY_WIDTH<480)
        		adView = new AdView(this, AdSize.BANNER, "a150a0ece652e81");
        	//else
        		//adView = new AdView(this, AdSize., "a150a0ece652e81");
	        app = new App(context,null);
	        FrameLayout layout = new FrameLayout(this);
	        FrameLayout.LayoutParams gameParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
	                FrameLayout.LayoutParams.FILL_PARENT);
	        adsParams =new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 
	                FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.BOTTOM|android.view.Gravity.CENTER);
	        if (T.DISPLAY_WIDTH < 380) {
				adsParams.setMargins(-70, 0, -70, 0);
			}
	        layout.addView(app, gameParams);
	        layout.addView(adView, adsParams);
	        adView.loadAd(new AdRequest());
	        setContentView(layout);
        }
        else
        {
        	
        setContentView(R.layout.main_lay);
        app = (App)findViewById(R.id.gameBoard1);
       	adView = (AdView )findViewById(R.id.adView);
       	
       	
       	
       	
       	
        	/*adView = new AdView(this, AdSize.BANNER, "a1507931651aee5");
	        app = new App(context,null);
	        FrameLayout layout = new FrameLayout(this);
	        FrameLayout.LayoutParams gameParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
	                FrameLayout.LayoutParams.FILL_PARENT);
	        adsParams =new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 
	                FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.BOTTOM|android.view.Gravity.RIGHT); 
	        layout.addView(app, gameParams);
	        layout.addView(adView, adsParams);
	        adView.loadAd(new AdRequest());
	        setContentView(layout);*/
        }
        
        
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    protected void onPause() 
    {
		super.onPause();
		
			app.pause();
		T.soundtheme.Pause();
		T.SaveInfo();
	}
    @Override
	protected void onResume() 
	{
		super.onResume();
		
			app.resume();
			if(T.soundtheme!= null)
				T.soundtheme.Play();
			
	}
    @Override
	public boolean onTouchEvent(MotionEvent mo) 
	{
		
		app.touch(mo);
		int action = mo.getAction();
		switch(action)
		{
		case MotionEvent.ACTION_DOWN:
			
			
		break;
		
		case MotionEvent.ACTION_UP:
			
			
		break;
		case MotionEvent.ACTION_MOVE:
			
		break;

		}
		return true;
	}

	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
    
}
